<template>
<h1>猜数字游戏</h1>
  <input type="text" v-model="a">
  <button @click="f">猜一猜</button>
  <h3>结果是:{{result}}</h3>
  {{num}}
</template>
<script setup>
import {ref} from "vue";

let num=parseInt(Math.random()*100)+1;
const a=ref('')
const result=ref('')

const f=()=>{
  if (a.value>num){
    result.value="猜大了";

  }
  else if(a.value<num){
    result.value="猜小了";
  }else {
    result.value='正确';
  }
}

</script>


<style scoped>

</style>